<template>
	<div class="newCurriculumContainer">
		<el-dialog :visible.sync="isShow" custom-class="el-dialog-bg" :before-close="handleClose" :close-on-click-modal="false">
			<div slot="title" class="panel_title">
				<span>{{ componentname }}</span>
			</div>
			<el-form ref="form1" label-width="140px" class="ruleForm" :model="curriculumInfo">
				<el-form-item label="课程名称" prop="courseName">
					<el-input
						v-model="curriculumInfo.courseName"
						maxlength="30"
						:disabled="!curriculumInfo.isEditableOfCourseName"
						style="width:45%"
						placeholder="请输入课程名称"
					></el-input>
				</el-form-item>
				<el-form-item label="课程类型" prop="courseType">
					<el-select
						v-model="curriculumInfo.courseType"
						placeholder="请选择课程类型"
						@change="courseModeChange"
						:disabled="!curriculumInfo.isEditableOfChargeMode"
						:style="{ width: curriculumInfo.courseTypeWidth }"
					>
						<el-option v-for="item in curriculumInfo.courseTypeList" :key="item.dicValue" :label="item.name" :value="item.dicValue"></el-option>
					</el-select>
					<el-select
						v-model="curriculumInfo.courseTeaacher2Id"
						style="margin-left: 20px;"
						placeholder="请选择双师课程"
						:disabled="!curriculumInfo.isEditableOfChargeMode"
						@change="courseTeaacherChange"
						v-if="curriculumInfo.courseType == 4"
					>
						<el-option
							v-for="item in curriculumInfo.teacherCourseList"
							:key="item.courseTeaacher2Id"
							:label="item.teacher2CourseName"
							:value="item.courseTeaacher2Id"
						></el-option>
					</el-select>
					<el-radio-group
						style="margin-left: 20px;"
						v-model="curriculumInfo.foreignTeacherType"
						v-if="curriculumInfo.courseTeaacher2Id != '' && curriculumInfo.courseType == 4"
						:disabled="!curriculumInfo.isEditableOfChargeMode"
						@change="handleTeacherChange"
					>
						<el-radio border :label="item.foreignTeacherType" v-for="item in curriculumInfo.foreignTeacherTypeList" v-bind:key="item.foreignTeacherType">
							{{ item.foreignTeacherTypeName }}
						</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item style="margin-top: -0.2rem;margin-bottom:0rem;" v-if="curriculumInfo.courseType != ''">
					<div v-if="curriculumInfo.courseType == 1">
						<span style="color:red;">*</span>
						一个老师教一个学生，此种课程需要预约上课
					</div>
					<div v-else-if="curriculumInfo.courseType == 2">
						<span style="color:red;">*</span>
						一个或多个老师对应多名学员，有固定的排课计划。全天或半天开课，签到按天进行
					</div>
					<div v-else-if="curriculumInfo.courseType == 3">
						<span style="color:red;">*</span>
						班级的课程是按课时来上，即一天只有一个或两个小时。签到按小时或分钟进行
					</div>
					<div v-else-if="curriculumInfo.courseType == 4">
						<span style="color:red;">*</span>
						指一堂课里有线上和线下两位教师上课
					</div>
				</el-form-item>
				<el-form-item label="所属科目" prop="subjectId">
					<el-select v-model="curriculumInfo.subjectId" :disabled="!curriculumInfo.isEditableOfChargeMode" placeholder="请选择所属科目" style="width:45%; ">
						<el-option v-for="item in curriculumInfo.subjectList" :key="item.subjectId" :label="item.name" :value="item.subjectId"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="班级课程设置" prop="courseMode" v-if="curriculumInfo.courseType == 2">
					<div v-for="item in curriculumInfo.courseItemEntityList" class="charge_item">
						<el-input style="width:20%" maxlength="9" :disabled="item.use" v-model="item.courseItemName" placeholder="班级课程名称"></el-input>
						&nbsp;&nbsp;
						<el-input
							style="width:20%"
							maxlength="3"
							:disabled="item.use"
							onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
							oninput="value=value.replace(/[^\d]/g,'')"
							v-model="item.oneCourseHourMinute"
							placeholder="班级课程时长"
						></el-input>
						&nbsp;&nbsp;分钟
						<span class="add_btn" @click="addCourse()"></span>
						<span class="reduce_btn" v-if="!item.use" @click="deleteCourse(item)"></span>
					</div>
				</el-form-item>
			</el-form>
			<div class="line_from"></div>
			<el-form ref="form2" label-width="140px" class="ruleForm">
				<el-form-item label="授课模式" prop="courseMode">
					<el-radio-group v-model="curriculumInfo.courseMode">
						<el-radio border :disabled="!curriculumInfo.isEditableOfChargeMode" v-for="item in curriculumInfo.courseModeList" :key="item.value" :label="item.value">
							{{ item.name }}
						</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="开课校区" prop="classtext" v-if="curriculumInfo.isShowSchool">
					<el-radio-group v-model="curriculumInfo.classtext" @change="handleCheckedCitiesChange" :disabled="!curriculumInfo.isEditableOfChargeMode">
						<el-radio border :label="1">所有校区</el-radio>
						<el-radio border :label="2">指定校区</el-radio>
					</el-radio-group>
					<el-select
						v-model="curriculumInfo.selectSchoolList"
						multiple
						collapse-tags
						:disabled="!curriculumInfo.isEditableOfChargeMode"
						style="margin-left: 20px;"
						placeholder="请选择校区"
						v-if="curriculumInfo.isShowSchoolView"
						@change="schoolChange"
					>
						<el-option v-for="item in curriculumInfo.classList" :key="item.campusId" :label="item.name" :value="item.campusId"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="收费模式" prop="chargeMode">
					<el-radio-group v-model="curriculumInfo.chargeMode" @change="handleradioChange" v-if="curriculumInfo.courseType == 2">
						<el-radio border :disabled="!curriculumInfo.isEditableOfChargeMode" v-for="item in activeChargeModeList" :key="item.name" :label="item.value">
							{{ item.name }}
						</el-radio>
					</el-radio-group>
					<el-radio-group v-model="curriculumInfo.chargeMode" @change="handleradioChange" v-else-if="curriculumInfo.courseType == 4">
						<el-radio border :disabled="!curriculumInfo.isEditableOfChargeMode" v-for="item in activeModeList" :key="item.name" :label="item.value">
							{{ item.name }}
						</el-radio>
					</el-radio-group>
					<el-radio-group v-model="curriculumInfo.chargeMode" @change="handleradioChange" v-else>
						<el-radio border :disabled="!curriculumInfo.isEditableOfChargeMode" v-for="item in chargeModeList" :key="item.name" :label="item.value">
							{{ item.name }}
						</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="定价标准" v-if="curriculumInfo.chargeMode != ''">
					<span v-for="item in curriculumInfo.schoolText" class="school_item">{{ item }}</span>
				</el-form-item>
				<el-form-item  v-if="curriculumInfo.chargeMode != ''">
					<div v-if="curriculumInfo.chargeMode == '1' && curriculumInfo.courseType == 4">
						<div  v-for="item in curriculumInfo.coursePackageEntityList" class="charge_item">
							<span v-clipboard:copy="item.coursePackageId">按课时：</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:12%;"
								@change="valueChange"
								v-model="item.syllabusNum"
								:disabled="!curriculumInfo.isEditableOfChargeMode"
								:min="1"
								:max="curriculumInfo.maxCourseLength"
							></el-input-number>
							<span style="width:25%">节课 =</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								:disabled="true"
								style="width:15%;"
								v-model="item.courseHour"
								:min="1"
								:max="99999"
							></el-input-number>
							<span style="width:25%">课时 =</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:15%;"
								v-model="item.totalMoney"
								:disabled="!curriculumInfo.isEditableOfChargeMode && !curriculumInfo.isExtend"
								:precision="2"
								:step="0.01"
								:min="0"
								:max="99999"
							></el-input-number>
							&nbsp;&nbsp;元
						</div>
					</div>
					<div v-else-if="curriculumInfo.chargeMode == '1' && curriculumInfo.courseType != 4">
						<div v-for="item in curriculumInfo.coursePackageEntityList" class="charge_item">
							<span v-clipboard:copy="item.coursePackageId">按课时：</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:12%;"
								v-model="item.courseHour"
								:min="1"
								:max="9999"
							></el-input-number>
							<span style="width:25%">课时 =</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:15%;"
								v-model="item.totalMoney"
								:precision="2"
								:step="0.01"
								:min="0"
								:max="99999"
							></el-input-number>
							&nbsp;&nbsp;元
							<span class="add_btn" @click="addPrice(curriculumInfo.chargeMode)"></span>
							<span class="reduce_btn" v-if="item.isErasable" @click="deletePrice(item)"></span>
						</div>
					</div>
					<div v-else-if="curriculumInfo.chargeMode == '2'">
						<div v-for="item in curriculumInfo.coursePackageEntityList" class="charge_item">
							<span v-clipboard:copy="item.coursePackageId">按期：</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:12%;"
								v-model="item.courseHour"
								:min="1"
								:max="9999"
							></el-input-number>
							<span style="width:25%">课时 =</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:15%;"
								v-model="item.totalMoney"
								:precision="2"
								:step="0.01"
								:min="0"
								:max="99999"
							></el-input-number>
							&nbsp;&nbsp;元/期
						</div>
					</div>
					<div v-else-if="curriculumInfo.chargeMode == '3'">
						<div v-for="item in curriculumInfo.coursePackageEntityList" class="charge_item">
							<span v-clipboard:copy="item.coursePackageId">按时间：</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:12%;"
								v-model="item.courseHour"
								:min="1"
								:max="9999"
							></el-input-number>
							<el-select v-model="item.courseTimeMode" type="number" placeholder="请选择" style="width:10%; ">
								<el-option v-for="item in curriculumInfo.courseTimeModeList" :key="item.name" :label="item.name" :value="item.value"></el-option>
							</el-select>
							<span>=</span>
							<el-input-number
								size="small"
								controls-position="right"
								class="newclassroomNumber"
								style="width:15%;"
								v-model="item.totalMoney"
								:precision="2"
								:step="0.01"
								:min="0"
								:max="99999"
							></el-input-number>
							&nbsp;&nbsp;元
							<span class="add_btn" @click="addPrice(curriculumInfo.chargeMode)"></span>
							<span class="reduce_btn" v-if="item.isErasable" @click="deletePrice(item)"></span>
						</div>
					</div>
				</el-form-item>
			</el-form>
			<div class="line_from"></div>
			<el-form ref="form3" class="ruleForm">
				<el-form-item label="课时消耗设定" label-width="140px"></el-form-item>
				<el-form-item label-width="100px">
					<div>
						<el-radio :disabled="!curriculumInfo.isEditableOfChargeMode" v-model="curriculumInfo.consumeMode" :label="1">按签到核算消课</el-radio>
						请假
						<el-input-number
							size="small"
							controls-position="right"
							class="newclassroomNumber"
							style="width:20%;margin:0 10px;"
							v-model="curriculumInfo.offsetDay"
							:disabled="!curriculumInfo.isEditableOfChargeMode"
							:min="1"
							:max="9999"
						></el-input-number>
						次核算消课
					</div>
					<div><el-radio v-model="curriculumInfo.consumeMode" :disabled="!curriculumInfo.isEditableOfChargeMode" :label="2">按开课时间核算消课</el-radio></div>
				</el-form-item>
			</el-form>
			<div class="btn_div">
				<div class="btn_sure" @click="submitForm('curriculumInfo')">确 认</div>
				<div class="btn_cancel" @click="resetForm('curriculumInfo')">取 消</div>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import { mapState, mapGetters, mapActions } from 'vuex'; //先要引入
let vm;
export default {
	props: ['componentname'],
	data() {
		return {
			inputVisible: false,
			inputValue: '',
			chargeModeList: []
		};
	},
	methods: {
		/**
		 * 选择双师课程
		 */
		courseTeaacherChange(val) {
			let currentCourseTeaacher = vm.curriculumInfo.teacherCourseList.find(function(item) {
				return item.courseTeaacher2Id == val;
			});
			if (vm.curriculumInfo.foreignTeacherType == '') return;
			vm.curriculumInfo.coursePackageEntityList[0].syllabusNum = currentCourseTeaacher.syllabusCount;
			vm.curriculumInfo.maxCourseLength = currentCourseTeaacher.syllabusCount;
			vm.curriculumInfo.coursePackageEntityList[0].courseHour = currentCourseTeaacher.syllabusCount * vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusHour;
			vm.curriculumInfo.coursePackageEntityList[0].totalMoney = currentCourseTeaacher.syllabusCount * vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusPrice;
		},
		/**
		 * 选择外教老师
		 */
		handleTeacherChange(val) {
			vm.curriculumInfo.foreignTeacherTypeList.forEach(item => {
				if (item.foreignTeacherType == val) {
					vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusPrice = item.oneSyllabusPrice;
					vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusHour = item.oneSyllabusHour;
					let currentCourseTeaacher = vm.curriculumInfo.teacherCourseList.find(function(item) {
						return item.courseTeaacher2Id == vm.curriculumInfo.courseTeaacher2Id;
					});
					vm.curriculumInfo.coursePackageEntityList[0].syllabusNum = currentCourseTeaacher.syllabusCount;
					vm.curriculumInfo.maxCourseLength = currentCourseTeaacher.syllabusCount;
					vm.curriculumInfo.coursePackageEntityList[0].courseHour = vm.curriculumInfo.coursePackageEntityList[0].syllabusNum * item.oneSyllabusHour;
					vm.curriculumInfo.coursePackageEntityList[0].totalMoney = vm.curriculumInfo.coursePackageEntityList[0].syllabusNum * item.oneSyllabusPrice;
				}
			});
		},
		courseModeChange(val) {
			console.log(val);
			vm.curriculumInfo.courseTypeWidth = '45%';
			if (val == 2) {
				this.curriculumInfo.chargeMode = 3;
				this.curriculumInfo.coursePackageEntityList = [];
				this.curriculumInfo.coursePackageEntityList.push({
					chargeMode: 3,
					courseTimeMode: 1,
					courseHour: '',
					syllabusNum: '',
					cycle: 10,
					totalMoney: '',
					isErasable: true
				});
			} else if (val == 4) {
				vm.curriculumInfo.courseTypeWidth = '10%';
				this.curriculumInfo.chargeMode = 1;
				this.curriculumInfo.coursePackageEntityList = [];
				this.curriculumInfo.coursePackageEntityList.push({
					chargeMode: 1,
					courseTimeMode: 1,
					courseHour: '',
					syllabusNum: '',
					cycle: 10,
					totalMoney: '',
					isErasable: true
				});
			} else {
				this.curriculumInfo.chargeMode = 1;
				this.curriculumInfo.coursePackageEntityList = [];
				this.curriculumInfo.coursePackageEntityList.push({
					chargeMode: 1,
					courseTimeMode: 1,
					courseHour: '',
					syllabusNum: '',
					cycle: 10,
					totalMoney: '',
					isErasable: true
				});
			}
		},
		deleteCourse(item) {
			if (this.curriculumInfo.courseItemEntityList.length == 1) {
				this.curriculumInfo.courseItemEntityList = [];
				this.curriculumInfo.courseItemEntityList.push({
					courseItemName: '',
					oneCourseHourMinute: '',
					use: false
				});
			} else {
				this.curriculumInfo.courseItemEntityList.splice(this.curriculumInfo.courseItemEntityList.indexOf(item), 1);
			}
		},

		addCourse() {
			this.curriculumInfo.courseItemEntityList.push({
				courseItemName: '',
				oneCourseHourMinute: '',
				use: false
			});
		},
		resetFormRules() {
			// this.$refs['form1'].resetFields();
			// this.$refs['form2'].resetFields();
			// this.$refs['form3'].resetFields();
		},
		valueChange(val) {
			vm.curriculumInfo.coursePackageEntityList[0].courseHour = val * vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusHour;
			vm.curriculumInfo.coursePackageEntityList[0].totalMoney = val * vm.curriculumInfo.coursePackageEntityList[0].oneSyllabusPrice;
		},
		/**
		 * 选择指定校区
		 */
		schoolChange(val) {
			console.log(val);
			this.curriculumInfo.schoolText = [];
			this.curriculumInfo.courseCampusEntityList = [];
			for (let i = 0; i < val.length; i++) {
				this.curriculumInfo.courseCampusEntityList.push({
					campusId: val[i]
				});
				for (let y = 0; y < this.curriculumInfo.classList.length; y++) {
					if (val[i] == this.curriculumInfo.classList[y].campusId) {
						this.curriculumInfo.schoolText.push(this.curriculumInfo.classList[y].name);
					}
				}
			}
		},
		/**
		 * 收费模式change
		 */
		handleradioChange(val) {
			console.log(val);
			this.curriculumInfo.coursePackageEntityList = [];
			this.curriculumInfo.coursePackageEntityList.push({
				chargeMode: val,
				courseTimeMode: 1,
				courseHour: '',
				syllabusNum: '',
				cycle: 10,
				totalMoney: '',
				isErasable: true
			});
		},
		/**
		 * 选择所有校区/指定校区
		 */
		handleCheckedCitiesChange(value) {
			console.log(value);
			if (value == 1) {
				this.curriculumInfo.courseCampusEntityList = this.curriculumInfo.classList;
				this.curriculumInfo.isShowSchoolView = false;
				this.curriculumInfo.schoolText = ['所有校区'];
				this.curriculumInfo.selectSchoolList = [];
			} else {
				this.curriculumInfo.courseCampusEntityList = [];
				this.curriculumInfo.isShowSchoolView = true;
			}
		},
		/**
		 * 删除收费标准
		 */
		deletePrice(item) {
			console.log(item.chargeMode);
			var index = vm.curriculumInfo.coursePackageEntityList.indexOf(item);
			if (index !== -1) {
				vm.curriculumInfo.coursePackageEntityList.splice(index, 1);
			}
			console.log(vm.curriculumInfo.coursePackageEntityList.length);
			if (vm.curriculumInfo.coursePackageEntityList.length === 0) {
				vm.curriculumInfo.coursePackageEntityList.push({
					chargeMode: item.chargeMode,
					courseTimeMode: 1,
					courseHour: '',
					syllabusNum: '',
					cycle: 10,
					totalMoney: '',
					isErasable: true
				});
			}
		},
		/**
		 * 添加收费标准
		 */
		addPrice(val) {
			this.curriculumInfo.coursePackageEntityList.push({
				chargeMode: val,
				courseTimeMode: 1,
				courseHour: '',
				syllabusNum: '',
				cycle: 10,
				totalMoney: '',
				isErasable: true
			});
		},
		/**
		 * 提交数据
		 */
		submitForm(formName) {
			if (this.curriculumInfo.courseName == '') {
				this.$message.warning('课程名称不能为空');
				return;
			}
			if (!tool.judge('classname', this.curriculumInfo.courseName)) {
				this.$message.warning('请输入有效的课程名称');
				return;
			}
			if (this.curriculumInfo.courseType == '') {
				this.$message.warning('课程类别不能为空');
				return;
			}
			if (this.curriculumInfo.subjectId == '') {
				this.$message.warning('科目不能为空');
				return;
			}
			if (this.curriculumInfo.coursePackageEntityList.length == 0) {
				this.$message.warning('收费标准不能为空');
				return;
			}
			for (let i = 0; i < this.curriculumInfo.coursePackageEntityList.length; i++) {
				if (this.curriculumInfo.coursePackageEntityList[i].courseHour == '' || this.curriculumInfo.coursePackageEntityList[i].courseHour == 0) {
					this.$message.warning('收费标准中课时不能为零或空');
					return;
				}
				if (this.curriculumInfo.coursePackageEntityList[i].totalMoney == '' || this.curriculumInfo.coursePackageEntityList[i].totalMoney == 0) {
					this.$message.warning('收费标准中金额不能为零或空');
					return;
				}
			}
			if (this.curriculumInfo.courseCampusEntityList.length == 0) {
				this.$message.warning('开课校区不能为空');
				return;
			}

			let paras = {
				courseName: this.curriculumInfo.courseName,
				courseType: this.curriculumInfo.courseType,
				subjectId: this.curriculumInfo.subjectId,
				courseMode: this.curriculumInfo.courseMode,
				chargeMode: this.curriculumInfo.chargeMode,
				offsetDay: this.curriculumInfo.offsetDay,
				createOrgId: this.curriculumInfo.createOrgId,
				remark: this.curriculumInfo.remark,
				coursePackageEntityList: this.curriculumInfo.coursePackageEntityList,
				courseCampusEntityList: [],
				courseItemEntityList: [],
				consumeMode: this.curriculumInfo.consumeMode
			};
			if (vm.curriculumInfo.courseType == 2) {
				for (let i = 0; i < this.curriculumInfo.courseItemEntityList.length; i++) {
					if (!tool.judge('classname', this.curriculumInfo.courseItemEntityList[i].courseItemName)) {
						this.$message.warning('请输入有效的班级课程名称');
						return;
					}
					if (this.curriculumInfo.courseItemEntityList[i].oneCourseHourMinute == '') {
						this.$message.warning('请输入班级课程时长');
						return;
					}
					if (this.curriculumInfo.courseItemEntityList[i].oneCourseHourMinute > 480) {
						this.$message.warning('输入的班级课程时长不能大于480，请重新输入');
						this.curriculumInfo.courseItemEntityList[i].oneCourseHourMinute = '';
						return;
					}
					paras.courseItemEntityList.push({
						courseItemName: this.curriculumInfo.courseItemEntityList[i].courseItemName,
						oneCourseHourMinute: this.curriculumInfo.courseItemEntityList[i].oneCourseHourMinute,
						use: this.curriculumInfo.courseItemEntityList[i].use,
						orderBy: i + 1
					});
				}
			} else if (vm.curriculumInfo.courseType == 4) {
				if (vm.curriculumInfo.courseTeaacher2Id == '') {
					this.$message.warning('请选择双师课程');
					return;
				}
				if (vm.curriculumInfo.foreignTeacherType == '') {
					this.$message.warning('请选择双师教师类型');
					return;
				}
			}
			paras.courseTeaacher2Id = vm.curriculumInfo.courseTeaacher2Id;
			paras.foreignTeacherType = vm.curriculumInfo.foreignTeacherType;
			this.curriculumInfo.courseCampusEntityList.forEach(item => {
				paras.courseCampusEntityList.push({
					campusId: item.campusId
				});
			});
			//courseCampusEntityList: this.curriculumInfo.courseCampusEntityList
			if (this.componentname == '新建课程') {
				api.courseAdd(paras).then(function(data) {
					if (data.resultCode == 2000) {
						vm.$store.dispatch('createCurriculum/hidecreateCurriculumPanel');
						vm.$message({
							message: '新建课程成功',
							type: 'success'
						});
						vm.$parent.searchCurriculum(); //刷新父组件
					} else {
						vm.$message.error(data.message);
					}
				});
			} else if (this.componentname == '课程信息编辑') {
				paras.courseId = vm.curriculumInfo.courseId + '';
				api.courseUpdate(paras).then(function(data) {
					if (data.resultCode == 2000) {
						vm.$store.dispatch('createCurriculum/hidecreateCurriculumPanel');
						vm.$message({
							message: '编辑成功',
							type: 'success'
						});
						vm.$parent.searchCurriculum(); //刷新父组件
					} else {
						vm.$message.error(data.message);
					}
				});
			} else if (this.componentname == '课程信息拓展') {
				paras.courseId = vm.curriculumInfo.courseId + '';
				paras.courseCampusEntityList = [];
				paras.courseCampusEntityList.push({
					campusId: vm.$store.state.campusId
				});
				api.courseExtend(paras).then(function(data) {
					if (data.resultCode == 2000) {
						vm.$store.dispatch('createCurriculum/hidecreateCurriculumPanel');
						vm.$message({
							message: '拓展成功',
							type: 'success'
						});
						vm.$parent.searchCurriculum(); //刷新父组件
					} else {
						vm.$message.error(data.message);
					}
				});
			}
			this.resetFormRules();
		},
		resetForm(formName) {
			this.resetFormRules();
			this.$store.dispatch('createCurriculum/hidecreateCurriculumPanel');
		},
		initData() {},
		handleClose() {
			console.log(this.curriculumInfo)
			this.resetFormRules();
			this.$store.dispatch('createCurriculum/hidecreateCurriculumPanel');
		}
	},
	computed: {
		...mapState({
			isShow: state => state.createCurriculum.createCurriculumDialog
		}),
		...mapGetters('createCurriculum', {
			curriculumInfo: 'getCurriculumInfo',
			curriculumId: 'getCurriculumId'
		}),
		activeChargeModeList: function() {
			return this.chargeModeList.filter(function(item) {
				return item.value != 1 && item.value != 2;
			});
		},
		activeModeList: function() {
			return this.chargeModeList.filter(function(item) {
				return item.value == 1;
			});
		}
	},
	mounted() {
		vm = this;
		let dicdata = tool.getItem(lsKey.dict, true);
		vm.chargeModeList = dicdata['charge_mode'];

		//	this.initData();
		console.log(this.curriculumInfo);
	}
};
</script>
<style scoped src="@/style/clue_manage/clue_add.css"></style>
<style lang="scss">
.newCurriculumContainer {
	.el-tag + .el-tag {
		margin-left: 10px;
	}
	.button-new-tag {
		margin-left: 10px;
		height: 32px;
		line-height: 30px;
		padding-top: 0;
		padding-bottom: 0;
	}
	.input-new-tag {
		width: 90px;
		margin-left: 10px;
		vertical-align: bottom;
	}
	.el-form-item__label::before {
		content: '*';
		color: #f56c6c;
		margin-right: 0.04rem;
	}
	.el-dialog-bg {
		background: #ffffff;
		width: 9.96rem;
		border-radius: 0.1rem;
	}
	.panel_title {
		font-size: 0.22rem;
		color: #333333;
		padding: 0.03rem 0.07rem 0rem 0.1rem;
	}
	.ruleForm {
		font-size: 16px;
		color: #666666;
	}
	.el-form-item__label {
		font-size: 16px;
		color: #666666;
	}

	/*底部按钮*/
	.btn_div {
		width: 3.5rem;
		margin: 0 auto;
		padding: 0.3rem 0 0 0;
		overflow: hidden;
	}
	.btn_div > div {
		width: 1.6rem;
		height: 0.4rem;
		line-height: 0.4rem;
		float: left;
		font-size: 0.16rem;
		text-align: center;
		border-radius: 0.05rem;
		cursor: pointer;
		user-select: none;
	}

	.btn_disable {
		color: #999999;
		background-color: #dedede;
		margin-right: 0.3rem;
		cursor: not-allowed !important;
	}
	.btn_sure {
		color: white;
		background-color: #3885f8;
		margin-right: 0.3rem;
	}
	.btn_sure:hover {
		background-color: rgba(56, 133, 248, 0.8);
	}
	.btn_cancel {
		color: #666666;
		border: 0.01rem solid #c0c4cc;
	}
	.btn_cancel:hover {
		background-color: rgba(56, 133, 248, 0.1);
	}
	.el-form-item {
		margin-bottom: 0.1rem;
	}
	.line_from {
		height: 1px;
		margin: 0.24rem 0.18rem 0.18rem 0.18rem;
		background-color: #f3f6fc;
	}
	.charge_item {
		font-size: 16px;
		color: #333333;
	}
	.school_item {
		font-size: 14px;
		border-radius: 0.05rem;
		background-color: #ebf5ff;
		color: #409eff;
		border: 0.01rem solid #cde6ff;
		padding: 0.05rem 0.1rem;
		margin-right: 0.1rem;
	}
	.newclassroomNumber {
		.el-input__inner {
			border-radius: 0.04rem !important;
		}
	}
}
</style>
